﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<ICategory>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:"Categories".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%: "Categories".Localize()%></h3>
    <%: Html.Partial("Toolbar") %>
    <div class="table-container">
        <%using (Html.BeginForm("Delete", "Category"))
          { %>
        <table id="category-table">
            <thead>
                <tr>
                    <th>
                        <%: "Name".Localize()%>
                    </th>
                    <th>
                        <%:"Description".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Add child".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Edit".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Delete".Localize()%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <% 
var index = 0;
foreach (var item in Model)
{
    index++;
                %>
                <tr id="node-<%:item.Id %>" class="item  <%=item.Parent==null?"":"child-of-node-"+item.Parent.Id %>  <%= (index % 2 ==0)?"even":"" %>">
                    <td class="category-item">
                        <span class='<%if(item.Children.Count() == 0){%>file<%} else {%>folder<%} %>'>
                            <%: item.Name%>
                        </span>
                    </td>
                    <td>
                        <%: item.Description %>
                    </td>
                    <td class="action">
                        <%: Html.ActionLink(" ", "Create", new { Controller = "Category", ParentId = item.Id }, new { @class = "o-icon add" })%>
                    </td>
                    <td class="action">
                        <%: Html.ActionLink(" ", "Edit", new { Controller = "Category", Id = item.Id }, new { @class = "o-icon edit" })%>
                    </td>
                    <td class="action">
                        <input type="submit" class="o-icon input-icon delete" name="id" value="<%: item.Id %>" />
                    </td>
                </tr>
                <%
}%></tbody>
        </table>
        <%} %>
    </div>
    <!-- Change Parent -->
    <form name="change-parent-form" id="change-parent" action="<%= ViewData["change-parent-action"] %>"
    method="post">
    <input name="id" type="hidden" />
    <input name="parentId" type="hidden" />
    </form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Require("category.index.js");
      } %>
</asp:Content>
